package br.ufc.DAO.Implements;

import org.hibernate.Session;
import org.hibernate.Transaction;

import br.ufc.DAO.IAlunoDisciplina;
import br.ufc.si.model.AlunoDisciplina;
import br.ufc.util.HibernateUtil;

public class AlunoDisciplinaDAO implements IAlunoDisciplina {

	public void save(AlunoDisciplina a) {
		Session sessao = HibernateUtil.getSession();

		Transaction txt = sessao.beginTransaction();

		try {
			sessao.save(a);
			txt.commit();
		} catch (Exception e) {
			txt.rollback();
		} finally {
			sessao.close();
		}

	}

	public void update(AlunoDisciplina a) {
		Session sessao = HibernateUtil.getSession();

		Transaction txt = sessao.beginTransaction();

		try {
			sessao.update(a);
			txt.commit();
		} catch (Exception e) {
			txt.rollback();
		} finally {
			sessao.close();
		}

	}

	public void delete(AlunoDisciplina a) {
		Session sessao = HibernateUtil.getSession();

		Transaction txt = sessao.beginTransaction();

		try {
			sessao.delete(a);
			txt.commit();
		} catch (Exception e) {
			txt.rollback();
		} finally {
			sessao.close();
		}

	}

}
